package team3132.utils;

/**
 * Provide a way to ensure only one thread is writing output so the outputs don't override each
 * other.
 */
public class SynchronizedOutput {
  // Singleton instance of SynchronizedOutput.

  private static SynchronizedOutput instance_ = new SynchronizedOutput();

  // Returns the singleton instance of SynchronizedOutput.
  public static SynchronizedOutput get() {
    return instance_;
  }

  // Make the constructor private so SynchronizedOutput cannot be created
  // outside of SynchronizedOutput.
  private SynchronizedOutput() {
  }

  // Synchronized method of System.out.println;
  public synchronized void println(String message) {
    System.out.println(message);
  }
}
